/****************************************************************************
**
****************************************************************************/

#include "chargeMain.h"

ChargeMain::ChargeMain(int no, QObject *parent) : QThread(parent),
    m_quit(false),
    m_cycle(100),
    gun_(nullptr)
{
    gun_ = new Gun(no);
}

ChargeMain::~ChargeMain()
{
    m_quit = true;
    wait();

    if (nullptr != gun_) {
        delete gun_;
        gun_ = nullptr;
    }
}

void ChargeMain::run()
{
    while (!m_quit) {
        gun_->Process();

        if (10 > m_cycle) {
            m_cycle = 10;
        }
        msleep(m_cycle);
    }
}

Gun *ChargeMain::gun() const
{
    return gun_;
}
